package org.space.ai.controller;

import com.galaxy.common.core.domain.R;
import lombok.RequiredArgsConstructor;
import org.space.ai.service.AiService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/ai")
@RequiredArgsConstructor
public class AiController {
    private final AiService aiService;

    @PostMapping("/check-forbidden-words")
    public Map<String, Object> checkForbiddenWords(@RequestBody Map<String, String> request) {
        String text = request.get("text");
        return aiService.checkForbiddenWords(text);
    }

    @GetMapping("/forbidden-word-categories")
    public Map<String, String> getForbiddenWordCategories() {
        return aiService.getForbiddenWordCategories();
    }

    @PostMapping("/recommend-drinks")
    public R<Map<String, Object>> recommendDrinks(@RequestBody Map<String, Object> request) {
        double temperature = Double.parseDouble(request.get("temperature").toString());
        double humidity = Double.parseDouble(request.get("humidity").toString());
        String windSpeed = request.get("windSpeed").toString();
        String windDirection = request.get("windDirection").toString();
        List<Map<String, Object>> products = (List<Map<String, Object>>) request.get("products");

        return R.ok(aiService.recommendDrinks(temperature, humidity, windSpeed, windDirection, products));
    }
}
